<?php include "conn.php";?>
<?
$Menu_table="newscata_product";
$Menu_OpenLink = "list.php";
$id=intval($_REQUEST["id"]);
if($id=="" || !is_numeric($id)){
    OutErrorBack("Error, please return!");
}
$conn = new Mysql();
$sql="select * from products where id = '$id'";
$rs =$conn->getRow($sql);
if($rs)
{
    $conn->query("update products set Linkcount = Linkcount + 1 where id = '$id'");
    $type=$rs["type"];
    $title = $rs["title"];
    $title_f=$rs["title_f"];
    $content=$rs["content"];
    $content1=$rs["content1"];
    $content2=$rs["content2"];
    $SiteTitle=$rs["adtitle"];
    $SiteKeywords=$rs["adkeyword"];
    $SiteDescription=$rs["adescription"];
    $px=$rs["px"];
    $ys_s_price=$rs["ys_s_price"];
    $ys_e_price=$rs["ys_e_price"];
    $pic1=$rs["pic"];
    $pic2=$rs["picall"];
    $is_hot=$rs["is_hot"];
    $is_tejia=$rs["is_tejia"];
    $styles=$rs["styles"];
    $objects=$rs["objects"];

}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?php echo $SiteTitle;?></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="keywords" content="<?php echo $SiteKeywords;?> ">
    <meta name="description" content="<?php echo $SiteDescription;?> " />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <?php include "public/cssjs.php";?>
    <link rel="stylesheet" type="text/css" href="css/product.css" />
</head>
<body>
<?php include "public/top.php";?>
<!--  -->
<div class="main-page">
    <div class="container">
        <div class="row">
            <div class="col-lg-6">
                <div class="home-someProducts-item overflow-hidden">
                    <div class="label"><strong><?php echo $objects;?></strong></div>
                    <div class="swiper1">
                        <div class="products_caption_picture" style="display: none;"></div>

                        <!-- Swiper -->
                        <div class="swiper-container gallery-top">
                            <div class="swiper-wrapper">
                                <div class="swiper-slide" style="background-image:url(/pic/<?php echo $pic1;?>)"></div>
                                <?php
                                $MyPicall=$pic2;
                                if($MyPicall!=""){

                                    $m=explode("|",$MyPicall);
                                    for($c=0;$c<count($m);$c++)
                                    {
                                        if($m[$c]!=""){
                                            ?>
                                            <div class="swiper-slide" style="background-image:url(/pic/<?php echo $m[$c];?>)"></div>

                                            <?
                                        }

                                    }


                                }
                                ?>


                            </div>
                        </div>
                        <div class="swiper-button-next swiper-button-white"></div>
                        <div class="swiper-button-prev swiper-button-white"></div>
                        <div class="swiper-container gallery-thumbs">
                            <!-- Add Arrows -->
                            <div class="swiper-wrapper">
                                <div class="swiper-slide" style="background-image:url(/pic/<?php echo $pic1;?>)"></div>
                                <?php

                                if($MyPicall!=""){


                                    for($c=0;$c<count($m);$c++)
                                    {
                                        if($m[$c]!=""){
                                            ?>
                                            <div class="swiper-slide" style="background-image:url(/pic/<?php echo $m[$c];?>)"></div>

                                            <?
                                        }

                                    }


                                }
                                ?>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-6">
                <div id="products-caption" class="products-caption text-left">
                    <h4 class="products-caption-title"><?php echo $title;?></h4>
                    <div class="products-caption-rating"><?php echo $styles;?></div>
                    <p class="products-caption-price"><small><del>¥<?php echo $ys_s_price;?></del></small>¥<?php echo $ys_e_price;?></p>
                    <p class="products-caption-desc"><?php echo  $title_f;?></p>
                    <!-- <p class="products-caption-size">尺寸：80x140x30厘米</p> -->
                    <?php
                    $con=new Mysql();
                    $sql2="select DISTINCT(attrtype) from d_attr where  shopid=0 and  pid=".$id." GROUP BY attrtype";
                    $rsa=$con->getAll($sql2);
                    foreach($rsa as $k=>$rs2){
                        ?>

                        <div class="products-caption-component">
                            <div class="title"><?php echo $rs2["attrtype"];?>：</div>
                            <ul class="color-group" >
                                <?php
                                $row=$con->getAll("select attr,pmoney,istype from d_attr where attrtype='".$rs2["attrtype"]."' and shopid=0 and pid=".$id);
                                foreach ($row as $k2=>$rs3){
                                    ?>
                                    <li  class="color-group-item" :style="background-image: url('<?php echo $rs3["pic"];?>');"><?php echo $rs3["attr"];?></li>
                                    <?php

                                }
                                ?>

                            </ul>
                        </div>
                        <?php

                    }
                    ?>

                    <p class="products-caption-size">服务：送货入户并安装</p>
                    <div class="row mb-4">
                        <div class="col-6">
                            <div class="input-group input-group-sm" style="max-width: 90px;">
                                <div class="input-group-prepend">
                                    <button @click="()=>{if(products_caption.number !=1) products_caption.number-= 1}" class="btn btn-outline-secondary" type="button">-</button>
                                </div>
                                <input type="text" v-model="products_caption.number" class="form-control text-center">
                                <div class="input-group-append">
                                    <button class="btn btn-outline-secondary" @click="()=>{products_caption.number+= 1}" type="button">+</button>
                                </div>
                            </div>
                        </div>
                        <div class="col-6"><div class="collection" @click="clickCollection"><i :class="{'active':collection}" class="iconfont icon-collection"></i>加入收藏</div></div>
                    </div>
                    <p><a href="shoppingCart.html" class="btn btn-block btn-lg btn-warning btn-cart"><i class="iconfont icon-gouwuche"></i>加入购物车</a></p>
                </div>
            </div>
        </div>
        <!--  -->
        <div class="page-content">
            <ul class="label-group">
                <li class="label active">商品详情</li>
                <li class="label">商品尺寸</li>
                <li class="label">组装和说明</li>
            </ul>
            <hr>
            <div class="article">
                <div class="article-body ">
                   <?php echo  $content;?>
                </div>
                <div class="article-body d-none">
                  <?php echo  $content2;?>
                </div>
                <div class="article-body d-none">
                  <?php echo  $content1;?>
                </div>

            </div>
        </div>
        <!--  -->
        <div class="page-groupBuying">
            <div class="home-heading">
                <h4 class="home-title"><span>推荐商品</span></h4>
            </div>
            <div class="home-body">
                <div class="row">
                    <?php
                    $sql_former = "select * from products where id<>".$id." and type=".$type." order by adate desc  limit 3";
                    $rsu2=$conn->getAll($sql_former);
                    foreach ($rsu2 as $key=>$rsu){
                        ?>

                        <div class="col-md-6 col-lg-4 mb-4">
                            <a href="#">
                                <div class="home-someProducts-item">
                                    <div class="label"><i class="iconfont icon-touxiang"></i><?php echo $rsu["Linkcount"]?></div>
                                    <div class="home-someProducts-img"><a href="#"><img class="hvr-grow" src="/pic/<?php echo $rsu["pic"]?>"></a>
                                        <div class="home-someProducts-action"><a href="#">加入购物车 <i class="iconfont icon-gouwuche"></i></a></div>
                                    </div>
                                    <div class="home-someProducts-caption">
                                        <div class="home-someProducts-title"><?php echo $rsu["title"]?></div>
                                        <div class="home-someProducts-rating"><?php echo $rsu["styles"]?></div>
                                        <div class="home-someProducts-price"><small>¥<?php echo $rsu["ys_s_price"]?></small>¥<?php echo $rsu["ys_e_price"]?></div>
                                    </div>
                                </div>
                            </a>
                        </div>
                        <?php
                    }
                    ?>


                </div>
            </div>
        </div>
        <!--  -->
    </div>
</div>
<!--  -->



<?php include "public/footer.php";?>
<?php include "public/bottom.php";?>
<script type="text/javascript" src="js/plugins/vue.min.js"></script>
<script type="text/javascript">
    // 模板引擎的数据写着里
    var Tdata={};
</script>
<script type="text/javascript" src="js/product-page.js"></script>
</body>

</html>